package com.wh.mail_demo.controller;

import com.wh.mail_demo.entity.MailEntity;
import com.wh.mail_demo.service.MailService;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.io.File;
import java.util.HashMap;
import java.util.Map;

@RestController
public class MailController {
    @Autowired
    MailService mailService;


    @RequestMapping("upload")
    public Map<String,Object> sendSimpleMail(@RequestBody MailEntity mails) throws  Exception{
        Map<String,Object> map=new HashMap<>();
        System.out.println(mails.getFrom());
        mailService.sendSimpleMail(mails.getFrom(),mails.getTo(),mails.getTo(),mails.getSubject(),mails.getContent(),mails.getName());
        map.put("code",2020);
        return map;
    }
}
